package org.danger.t7.common.meters;

import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.exporter.common.TextFormat;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * .
 */
@Controller
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PrometheusController {
    private final PrometheusMeterRegistry prometheusRegistry;
    private final PrometheusConf prometheusConf;


    /**
     * pull data
     *
     * @return .
     */
    @GetMapping(value = "/metrics", produces = "text/plain;version=0.0.4;charset=utf-8")
    @ResponseBody
    public String metrics() {
        return prometheusRegistry.scrape(TextFormat.CONTENT_TYPE_OPENMETRICS_100);
    }

}
